<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../../css/my/myintegral.css" />
	</head>

	<body>
		<div id="myintegral" v-cloak>
			<header class="mui-bar mui-bar-nav">
				<a class="mui-action-back mui-icon mui-icon-arrowleft mui-pull-left"></a>
				<h1 class="mui-title">我的积分</h1>
				<a class="mui-pull-right clsopen" href="../IntegralOrder/orderList.html">兑换记录</a>
			</header>
			<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
				<div class="mui-scroll">
					<div class="balance">
						<div>
							<div>{{data.score || 0}}</div>
							<div>当前积分</div>
						</div>
					</div>
					<div class="integral_data">
						<div class="integral_shop">
							<button type="button" class="mui-btn" @tap="openIntegral">
						<div>积分商城</div>
						<div>积分兑换礼品</div>
						</button>
						</div>
						<div class="integral_comment">
							<button type="button" class="mui-btn clsopen" href="../comment/myComment.html">
						<div>评论中心</div>
						<div>写评论的积分</div>
						</button>
						</div>
					</div>
					<div class="record" v-show="list.length>0">
						<div class="record_title">最近积分记录</div>
						<div class="record_list" v-for="list in list">
							<div class="record_data">
								<div>{{list.logDesc}}</div>
								<div class="time">{{list.addTimeStr}}</div>
							</div>
							<div class="record_num">{{list.integralNum}}</div>
						</div>
						<div></div>
					</div>
				</div>
			</div>
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/libs/vue.js"></script>
		<script src="../../js/libs/zepto.js"></script>
		<script src="../../js/common.js"></script>
		<script type="text/javascript">
			mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					up: {
						auto: true,
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
			})

			var myintegral = new Vue({
				el: '#myintegral',
				data: {
					imgCommonUrl: common.imageUrl,
					data: '',
					pageNum: 1,
					list: []
				},
				methods: {
					openIntegral: function() {
						common.open('integral.html', '../my/integral.html')
					}
				}
			})

			function pullupRefresh() {
				common.ajax('/integral/getList', {
					curPageNO: myintegral.pageNum++
				}, function(data) {
					if(data.code == 1) {
						if(myintegral.pageNum > data.data.pageCount) {
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
						} else {
							mui('#pullrefresh').pullRefresh().endPullupToRefresh();
						}
						myintegral.data = data.data
						myintegral.list = myintegral.list.concat(data.data.list)
						if(myintegral.list <= 0) {
							$(".mui-pull").hide()
						}
					} else {
						mui('#pullrefresh').pullRefresh().endPullupToRefresh();
						if(data.resultMsg) {
							common.toast(data.resultMsg)
						}
					}
				}, true, 'get')
			}
			document.addEventListener('myintegral', function() {
				myintegral.pageNum = 1
				myintegral.list = []
				mui('#pullrefresh').pullRefresh().refresh(true);
				mui('#pullrefresh').pullRefresh().pullupLoading();
				mui('#pullrefresh').pullRefresh().scrollTo(0, 0, 0.1);
			})
		</script>
	</body>

</html>